﻿using Microsoft.Xna.Framework.Input;
using RilattackLibrary;
using System.Timers;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Storage;

namespace RilattackGameWPF
{
    public class InputManager
    {
        public ControlablePlayer ControlablePlayer
        {
            get
            {
                throw new System.NotImplementedException();
            }

            set
            {

            }
        }

        public void CheckInput(object source, ElapsedEventArgs e)
        {
            KeyboardState stateKey = Keyboard.GetState();
            GamePadState statePad = GamePad.GetState(PlayerIndex.One);

            if (stateKey.IsKeyDown(Keys.D) || (statePad.IsConnected 
                && statePad.IsButtonUp(Buttons.LeftThumbstickLeft)
                && statePad.ThumbSticks.Left.X != 0
                ))
                App.Client.CurrentPlayer.MovementDirection.x = 1;
            else if (stateKey.IsKeyDown(Keys.A) || (statePad.IsConnected 
                && statePad.IsButtonUp(Buttons.LeftThumbstickRight)
                && statePad.ThumbSticks.Left.X != 0
                ))
                App.Client.CurrentPlayer.MovementDirection.x = -1;
            else
                App.Client.CurrentPlayer.MovementDirection.x = 0;

            if (stateKey.IsKeyDown(Keys.W) || (statePad.IsConnected 
                && statePad.IsButtonUp(Buttons.LeftThumbstickDown)
                && statePad.ThumbSticks.Left.Y != 0
                ))
                App.Client.CurrentPlayer.MovementDirection.y = -5;
            else                
                App.Client.CurrentPlayer.MovementDirection.y = 0;
        }
    }
}